from app01 import models
from django.views import View
from django.http import JsonResponse

class BaseResponse(object):
    def __init__(self):
        self.status=True
        self.data=None
        self.error=None

    @property
    def dict(self):
       return self.__dict__

class HookTemplateDetailView(View):

    def get(self,request,pk):
        br=BaseResponse()
        hkq_=models.HookTemplate.objects.filter(pk=pk).first()
        if not hkq_:
            br.status=False
            br.error='不存在该钩子模板'
        else:
            br.data=hkq_.content
        return JsonResponse(br.dict)